resource "alicloud_ram_role" "main" {
  name                  = "${var.ram_role_name}-role"
  document              = var.ram_role_document
  description           = var.ram_role_description
  force                 = var.role_force_destroy
}
resource "alicloud_ram_role_policy_attachment" "custom" {
  count                 = var.enable_custom_policy && length(var.attach_custom_policy_name) > 0 ? length(var.attach_custom_policy_name) : 0  
  policy_name           = element(var.attach_custom_policy_name, count.index)
  policy_type           = var.attach_custom_policy_type
  role_name             = alicloud_ram_role.main.name
}
resource "alicloud_ram_role_policy_attachment" "system" {
  count                 = var.enable_system_policy && length(var.attach_system_policy_name) > 0 ? length(var.attach_system_policy_name) : 0  
  policy_name           = element(var.attach_system_policy_name, count.index)
  policy_type           = var.attach_system_policy_type
  role_name             = alicloud_ram_role.main.name
}